using System;
using System.Collections.Generic;
using System.Text;

namespace Ent.Web.Helper
{
    public class MathFunction
    {
        public static bool ConvertToBoolean(object o, bool defaultValue)
        {
            try
            {
                return Convert.ToBoolean(o);
            }
            catch (Exception exc)
            {
                return defaultValue;
            }
        }
        public static bool ConvertToBoolean(object o)
        {
            return ConvertToBoolean(o, false);
        }
        public static int ConvertToInteger(object o, int defaultValue)
        {
            try
            {
                if (o == null)
                    return defaultValue;
                return Convert.ToInt32(o);
            }
            catch (Exception exc)
            {
                return defaultValue;
            }
        }
        public static int ConvertToInteger(object o)
        {
            return ConvertToInteger(o, -1);
        }
    }
}
